ihelpuoo.weboo.runtime.MessageSet = function(m)
{
	this.module = m;
	this.locales = null;
	this.defaultSet = null;
	this.fileName = null;
	this.HTML = null;
	this.activeLoacle = null;
}

ihelpuoo.weboo.runtime.MessageSet.prototype
=
{
	valueOf: function(ele)
	{
		this.fileName = ele.getAttribute("file-name");
		this.locales = ihelpuoo.util.map();
		for(var i=0;i<ele.childNodes.length;i++)
		{
			var node = ele.childNodes.item(i);
			if(node.nodeType == Node.ELEMENT_NODE)
			{
				var ls = new ihelpuoo.weboo.runtime.LocaleSet();
				ls.valueOf(node);
				if(ls.name=="default")
					this.defaultSet = ls;
				this.locales.put(ls.name,ls);
			}
		}
		this.activeLoacle = this.defaultSet;
	}
	
	,
	setActiveLocale: function(localeName)
	{
		if(null==localeName) return;
		if(this.activeLoacle)
			this.activeLoacle.HTML.hide();
			
		var lc = this.locales.get(localeName);
		if(null==lc) return;
		this.activeLoacle = lc;
		this.HTML.showMessages(lc);
	}
	
	,
	render: function()
	{
		if(null == this.HTML)
		{
			this.HTML = new ihelpuoo.weboo.runtime.MessageSetHTML(this.fileName);
			if(null==this.locales || this.locales.size==0)
				return this.HTML.shell;
			
			var values = this.locales.values();
			for(var i=0;i<values.length;i++)
			{
				var ls = values[i];
				this.HTML.addTab(this.module.name,ls);
			}
			this.HTML.showMessages(this.activeLoacle);
		}
		return this.HTML.shell;
	}
}